var files=[
	{
		name:"文件夹1",
		floder:true,
		ext:null
	},
	{
		name:"文件夹2",
		floder:true,
		ext:null
	},
	{
		name:"文件1",
		floder:false,
		ext:"txt"
	},
	{
		name:"文件2",
		floder:false,
		ext:"mp4"
	}
]

var computer={
	init:function(){
		var fileHtml='<div class="file"><i class="fa {{icon}}"></i><br/><span>{{name}}</span></div>';
		for(var i=0;i<files.length;i++){
			files[i].icon=computer.getIcon(files[i]);
			var html=common.replace(fileHtml,files[i]);
			$("#content").append(html);
		}
	},
	getIcon:function(file){
		if(file.floder){
			return "fa-folder-o";
		}
		if(!file.ext){
			return "fa-file-o";
		}
		var icon="fa-file-o";	
		switch(file.ext.toLocaleLowerCase()){
			case "txt":
				icon="fa-file-text";break;
			case "mp4":
			case "flv":
				icon="fa-file-video-o";break;
			case "mp3":
				icon="fa-file-audio-o";break;
			case "java":
			case "sql":
			case "js":
			case "css":
				icon="fa-file-code-o";break;
			case "jpg":
			case "png":
			case "bmp":
				icon="fa-file-photo-o";break;
			case "pdf":
				icon="fa-file-pdf-o";break;
			case "doc":
			case "docx":
				icon="fa-file-word-o";break;
			case "xls":
			case "xlsx":
				icon="fa-file-excel-o";break;
			case "ppt":
			case "pptx":
				icon="fa-file-powerpoint-o";break;
		}
		return icon;
	}
}

$(function(){
	computer.init();
})

